<%--
 *  File:    DoctorProdPopWindow.jsp
 *  @Author: Jamesli 
 *  Date:    2010/11/10
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.DoctorProdPopWindow");
  String strModuleName = "ERM";
  String contextPath = request.getContextPath();
  
  String readonly = request.getParameter("readonly");
  if(readonly == null)readonly = "N";
%>

<% //--------------------  include files list --%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<iframe name="reloadHandler" style="display:none" ></iframe>
<html>
<head>
<title>doctorProdPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_doctorprod"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/cn/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript">
function page_close(){
	window.close();
}

function page_add(){
    if (isEmpty(document.cform.prodid.value)){
    	alert("<%= message.getMessageDesc("Can_not_be_null",label.getLabelName("L_Product"))%>");
        return;
    }  
    cform.actionname.value = "add";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_delete(){
    if(isNullChecked(cform.delids))
    {
    	alert('<%= message.getMessageDesc("PLEASE_SELECT")%>');
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL")%>")) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function page_selectProd() {

		var status = "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "../../../masterdata/kdm/ProductSelect.jsp?<%= OvalTools.randomURL() %>";
		
		if (typeof popwindow1 != 'undefined') popwindow1.close();
		popwindow1 = window.open(url, "newwindow1", status);
}

function page_setproduct(id,umcode,prodcode,prodname)
{
    document.cform.prodid.value = id;
    document.cform.prodcode.value=prodcode;
    document.cform.prodname.value=prodname;
}

function page_checkProdCode(){
	var prodcode = document.cform.prodcode.value;
	
	document.cform.prodname.value = "";
	document.cform.prodid.value = "";
	
	if(isEmpty(prodcode)) {
		return;
	}
	
	document.cform.prodcode.value = "";
	
	var  datahandler = new  DataHandler() ;
	datahandler.add_params("prodcode" , prodcode,"String");
	datahandler.add_params("languagecode" , cform.languagecode.value,"String");
	datahandler.add_params("orgid" , cform.orgid.value,"Integer");
	datahandler.getResult("prodname","document.cform.prodname");
	datahandler.getResult("prodcode","document.cform.prodcode"); 
	datahandler.getResult("prodid","document.cform.prodid");
	datahandler.add_job("j_getprod") ;
	datahandler.runDataHandler();
}
</script>
<iframe name="reloadHandler" style="display:none" ></iframe>
<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher" >
  <input type="hidden" name="pagename" value="p_doctorprod">
  <input type="hidden" name="actionname">
  <custom:hidden property="doctorid"></custom:hidden>
  <custom:hidden property="languagecode" scope="session"/>
  <custom:hidden property="orgid" name="userinfo" scope="session"/>	
		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0">
		<tr class="deepblue-left"> 
		  	<td width="15%" class="deepblue-left">&nbsp;</td>
          	<td width="30%" class="title_center">&nbsp;<%= label.getLabelName("L_ProductCode") %></td>
	  		<td class="title_center">&nbsp;<%= label.getLabelName("L_ProductName") %></td>
	  	</tr>
	 <%
        int i = 0;
        String strClassType = new String();   
        Vector doctorprods = (Vector)pageContext.getAttribute("doctorprods");
        if(doctorprods == null)
        {
      	  doctorprods = new Vector();
        }
     %>
     <logic:iterate id="doctorprod" collection="<%= doctorprods %>">                      
     <%
       HashMap doctorprodMap = (HashMap)pageContext.getAttribute("doctorprod"); 
       if(i%2 == 1)
       {
         strClassType = "td-listrom";
       }else{                    
         strClassType = "";
       }  
       i++;        
     %>       
     <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" class="<%=JspHelper.filterNull( strClassType )%>">
      <td class="<%=JspHelper.filterNull( strClassType )%>">
      <%if(!readonly.equalsIgnoreCase("Y")){ %> 
        <custom:checkbox property="doctorprodid" name="doctorprod" changedName="delids" styleClass="checkbox"></custom:checkbox>
      <%}else{ %>
      	&nbsp;
      <%} %>
      </td>
      <td class="<%=JspHelper.filterNull( strClassType )%>"><custom:write property="prodcode" name="doctorprod"/></td>
      <td class="<%=JspHelper.filterNull( strClassType )%>"><custom:write property="prdn" name="doctorprod"/></td>
    </tr>
    </logic:iterate>
    <%if(!readonly.equalsIgnoreCase("Y")){ %> 
      	<tr >
         	<td>&nbsp;</td>
         	<td>
           		<input type="text" name="prodcode" onchange="javascript:page_checkProdCode();" style="width:80%">
           		<a onclick="javascript:page_selectProd();"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
            </td>
            <td><input type="text" name="prodname" readonly border="0"></td>
            <input type="hidden" name="prodid"> 
       	</tr>
    <%} %>
	</table>
	<%if(!readonly.equalsIgnoreCase("Y")){ %>		
	<table width="100%" cellspacing="0" cellpadding="0">
		<tr>
			<td class="summary_top"></td>
		</tr>
		<tr>
			<td class="td_center"><a onclick="javascript:page_add();"><custom:button type="1" label="L_Add" imgsrc="finish.gif" border="0" style="width:60"/></a>
			<a onclick="javascript:page_delete();"><custom:button type="1" label="L_Delete" imgsrc="finish.gif" border="0" style="width:60"/></a>
			<a onclick="page_close()"><custom:button type="1" label="L_Close" imgsrc="delete.gif" border="0" style="width:60"/></a></td>
			
		</tr>
	</table>
	<%} %>
</form>
</body>
</html>